﻿
using GalaSoft.MvvmLight.CommandWpf;
using HuiZe.education.View;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace HuiZe.education.ViewModel
{
    public class PopupViewModel : ViewModelBase
    {
        public RelayCommand<object> HidePopupViewCommand { get; set; }
        public FrameworkElement PopupContent { get; set; }

        public PopupViewModel()
        {
            HidePopupViewCommand = new RelayCommand<object>(HidePopupView);
        }

        private void HidePopupView(object obj)
        {
            UserControl userControl = obj as UserControl;
            PopupView targetWindow = Window.GetWindow(userControl) as PopupView;
            PopupContent = null;
            targetWindow.DoubleAnimationClose();
        }

        public void ShowPopupView(string viewName)
        {
            PopupView PopupView = new PopupView();
            PopupContent = GetFrameworkElement(viewName);
            PopupView.Show();
        }
    }
}
